<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>编辑推送组</title>
</head>
<body>
<div class="pageheader">
    <h2>推送组</h2>
</div>
<div class="contentpanel">
    <div class="panel panel-default">
        <form:form commandName="formDto" cssClass="form-horizontal form-bordered">
            <div class="form-group">
                <label class="col-sm-3 control-label">组名</label>

                <div class="col-sm-6">
                    <form:input path="name" cssClass="form-control" required="required" placeholder="推送组名"
                                maxlength="10"/>
                    <form:errors path="name" cssClass="error text-danger"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">推送表达式
                <span class="fa fa-info-circle" data-container="body" data-toggle="popover" data-placement="right"
                      data-content="
                            示例:'0 0 12 * * ?' 每天中午12点触发<br/>

                    '0 15 10 ? * *' 每天上午10:15触发<br/>

                    '0 15 10 * * ?' 每天上午10:15触发<br/>

                    '0 15 10 * * ? *' 每天上午10:15触发
                            " data-original-title="" title=""></span>
                </label>

                <div class="col-sm-6">
                    <form:input path="cronExpression" cssClass="form-control" required="required" id="cronExpression"
                                placeholder="推送触发表达式"/>
                    <span class="help-block">系统将根据填写的表达式向分组内的用户推送报表消息.</span>
                    <form:errors path="cronExpression" cssClass="error text-danger"/>

                    <c:forEach items="${formDto.allCronExpression}" var="item">
                        <button type="button" style="margin-top:5px;" class="btn btn-sm btn-success expressionItem"
                                value="${item.expression}">${item.name}</button>
                    </c:forEach>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">报表规则</label>

                <div class="col-sm-6">
                    <select class="form-control categoryList" name="reportRuleUuid">
                        <option value="" selected="selected">报表规则</option>
                        <c:forEach items="${formDto.reportRuleDtos}" var="i">
                            <option value="${i.uuid}" ${formDto.reportRuleUuid eq i.uuid?"selected":""}>${i.name}</option>
                        </c:forEach>
                        <form:errors path="reportRuleUuid" cssClass="error text-danger"/>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label"></label>

                <div class="col-sm-6">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <a href="javascript:window.history.go(-1);" class="btn btn-default">取消</a>
                </div>
            </div>
        </form:form>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $('[data-toggle="popover"]').popover({html: true});
        $(".expressionItem").click(function () {
            $("#cronExpression").val($(this).attr("value"));
        });
    })
</script>
</body>
</html>
